(ns core.main)

(defstruct user :id :first-name :last-name :user-name :password :email :is-logedin :is-admin)
(def users {})

(defn logout-user "This function will logedout user."
     [user] 
     (assoc user :is-logedin false))

(defn is-valid-user "Returns true if user is valid, othervise returns false."
     [user] 
     ())

(defn login-user "Try to login user."
     [user]
     (true? (is-valid-user user) assoc user :is-logedin true))

(defn register-user "Saves user into users list. The name-of-user will be key in resulting list." 
     [user name-of-user] 
     (assoc users (str ":" name-of-user) user))

(defn enter-user "Returns entered user" [] 
      (let [v_id (read-line)
            v_first-name (read-line)
            v_last-name (read-line)
            v_user-name (read-line)
            v_password (read-line)
            v_email (read-line)]
      (register-user (struct-map user :id v_id :first-name v_first-name :last-name v_last-name :user-name v_user-name :password v_password :email v_email :is-logedin false :is-admin false) (str "id" v_id))))                                

(defstruct room :number :num-of-beds :is-ocupated :price)
(def rooms {})

(defn save-room "The function that will save provided room." 
     [room room-key]
     (assoc rooms room-key room))

(defn create-room "This function will create room based on user input." []
     (let [v_number (read-line)
           v_num-of-beds (read-line)
           v_price (read-line)]
       (save-room (struct-map room :number v_number :num-of-beds v_num-of-beds :price v_price :is-ocupated false) (str "room" v_number))))

(defstruct service :id :name :price)
(def services {})

(defn save-service "The function that will save provided service." 
     [service service-key]
     (assoc services service-key service))

(defn create-service "This function will create service based on user input." []
     (let [v_id (read-line)
           v_name (read-line)
           v_price (read-line)]
       (save-service (struct-map service :id v_id :name v_name :price v_price) (str "id" v_id))))

(defn delete-room "Deletes provided room from default storage."
     [room]
     (dissoc rooms (str "room" room :number)))